﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:c="clr-namespace:personalplaner.common.controls"
                    xmlns:conv="clr-namespace:personalplaner.common.converters"
                    xmlns:p="clr-namespace:personalplaner.common.Properties">

    
    
    <!-- 
    *****************************************************************
    PrintControl Template 
    *****************************************************************
    -->

    <Style TargetType="{x:Type c:PrintControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type c:PrintControl}">

                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="250"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>

                        <GroupBox Margin="5,5,5,0" Padding="5" BorderThickness="0">
                            <Grid>
                                
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="60" Command="c:PrintControl.PrintCommand">
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition/>
                                                <RowDefinition Height="Auto"/>
                                            </Grid.RowDefinitions>
                                            <Image Source="/personalplaner.gui;component/resources/images/Printer_32.png" Width="32" />
                                            <TextBlock Text="Drucken" Grid.Row="1"/>
                                        </Grid>
                                    </Button>

                                    <GroupBox Header="Drucken" Grid.Column="1" Margin="5,0,5,0" Padding="0,5,0,0" BorderThickness="0">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition />
                                            </Grid.ColumnDefinitions>

                                            <TextBlock Text="Exemplare:" Margin="0,0,5,0" Grid.Column="0"/>

                                            <!--<c:NumericTextBox Grid.Column="1" Text="{TemplateBinding Copies}"/>-->
                                            <c:NumericTextBox Grid.Column="1" Text="{Binding Copies, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:PrintControl}}}"/>

                                        </Grid>
                                    </GroupBox>
                                </Grid>

                                <GroupBox Grid.Row="1" Header="{x:Static p:Resources.Drucker}" Padding="0,0,0,0" BorderThickness="0" Margin="0,10,0,0">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>

                                        <ComboBox ItemsSource="{TemplateBinding Printers}"  SelectedItem="{Binding SelectedPrinter, RelativeSource={RelativeSource TemplatedParent}}">
                                            <ComboBox.ItemTemplate>
                                                <DataTemplate>
                                                    <Grid>
                                                        <Grid.Resources>
                                                            <conv:PrinterNameToImageConverter x:Key="printerImageConv"/>
                                                        </Grid.Resources>
                                                        
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition/>
                                                            <RowDefinition/>
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="40"/>
                                                            <ColumnDefinition/>
                                                        </Grid.ColumnDefinitions>

                                                        <Image Grid.RowSpan="2" Source="{Binding FullName, Converter={StaticResource printerImageConv}}" Width="32"/>

                                                        <TextBlock Text="{Binding Name}" Grid.Column="1" FontWeight="SemiBold" Margin="0"/>
                                                        <TextBlock Text="{Binding FullName}" Foreground="#AA000000" Grid.Row="1" Grid.Column="1" Margin="0,0,0,3"/>

                                                    </Grid>
                                                </DataTemplate>
                                            </ComboBox.ItemTemplate>
                                        </ComboBox>

                                    </Grid>
                                </GroupBox>

                            </Grid>
                        </GroupBox>

                        <Border Background="Transparent" BorderBrush="Black" BorderThickness="1,0,0,0" Margin="5,5,5,0" Padding="5" Grid.Column="1">
                            <Grid>
                                <c:PrintPreviewItemsControl ItemsSource="{TemplateBinding Pages}" x:Name="PART_PrintPreview">
                                    <c:PrintPreviewItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <Grid Width="{Binding PaperWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:PrintControl}}}" Height="{Binding PaperHeight, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:PrintControl}}}">
                                                <ContentPresenter Content="{Binding .}"/>
                                            </Grid>
                                        </DataTemplate>
                                    </c:PrintPreviewItemsControl.ItemTemplate>
                                </c:PrintPreviewItemsControl>
                            </Grid>
                        </Border>
                    </Grid>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>